﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace VTFC
{
    // ----------------------------------------------------------------------------
    /// <summary>
    /// ListViewItem for binding of <see cref="VTFC.Document"/> instance.
    /// </summary>
    // ----------------------------------------------------------------------------
    public class ListViewItemDocument : ListViewItem
    {
        /// <summary><see cref="VTFC.Document"/> instance</summary>
        private Document document = null;

        // ----------------------------------------------------------------------------
        /// <summary>
        /// Get/set <see cref="VTFC.Document"/> instance and the subitem values.
        /// </summary>
        // ----------------------------------------------------------------------------
        public Document Document 
        {
            get
            {
                return document;
            }
            set
            {
                document = value;
                this.SubItems.Add(document.MetaData.FileName);
                this.SubItems.Add(document.MetaData.Modified.ToString(Resources.DateTimeFormater));
                if (document.IsCheckedOut)
                {
                    this.SubItems.Add(document.CheckedOutUserName);
                }
                else
                {
                    this.SubItems.Add(document.MetaData.ModifiedBy);
                }
                this.SubItems.Add(document.MetaData.Version);
                this.SubItems.Add(BaseLogic.GetSizeDisplay(document.MetaData.Size));
            }
        }//prop Document

        // ----------------------------------------------------------------------------
        /// <summary>
        /// Constructor.
        /// </summary>
        // ----------------------------------------------------------------------------
        public ListViewItemDocument()
        {
        }//ctor

        // ----------------------------------------------------------------------------
        /// <summary>
        /// Set ForeColor property of current item by <see cref="VTFC.Document"/> instance.
        /// </summary>
        // ----------------------------------------------------------------------------
        public void SetForeColor()
        {
            if (document != null)
            {
                this.BackColor = document.Skipped ? Constant.VTFC_SKIPPED_ITEM_BACKCOLOR : SystemColors.Window;
                this.ForeColor = document.IsCheckedOut ? Constant.VTFC_CHECKED_ITEM_FORECOLOR : Constant.VTFC_NORMAL_ITEM_FORECOLOR;
            }
            else
            {
                this.ForeColor = Constant.VTFC_OUTER_ITEM_FORECOLOR;
            }
        }//func SetForeColor
    }//class ListViewItemDocument
}//namespace VTFC
